home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / CMPLTPAS / FIBERGLS.PAS < prev    next >
Pascal/Delphi Source File  |  1988-09-02  |  2KB  |  53 lines

  1. {--------------------------------------------------------------}
  2. {                    PsychedelicFiberglas                      }
  3. {                                                              }
  4. {                             by Jeff Duntemann                }
  5. {                             Turbo Pascal V5.0                }
  6. {                             Last update 9/3/88               }
  7. {                                                              }
  8. { This program demonstrates palette-switching through the BGI. }
  9. { Children of the Sixties will understand the name.            }
  10. {                                                              }
  11. { From the book, COMPLETE TURBO PASCAL 5.0  by Jeff Duntemann  }
  12. {        Scott, Foresman & Co. 1988  ISBN 0-673-38355-5        }
  13. {--------------------------------------------------------------}
  14.  
  15. PROGRAM PsychedelicFiberglas;
  16.  
  17. USES Crt,Graph;
  18.  
  19. VAR
  20.   I,Color     : Integer;
  21.   Palette     : PaletteType;
  22.   GraphDriver : Integer;
  23.   GraphMode   : Integer;
  24.   ErrorCode   : Integer;
  25.  
  26. BEGIN
  27.   GraphDriver := Detect;  { Let the BGI determine what board we're using }
  28.   DetectGraph(GraphDriver,GraphMode);
  29.   InitGraph(GraphDriver,GraphMode,'');
  30.   IF GraphResult <> 0 THEN
  31.     BEGIN
  32.       Writeln('>>Halted on graphics error: ',GraphErrorMsg(GraphResult));
  33.       Halt(2)
  34.     END;
  35.  
  36.   Randomize;
  37.  
  38.   GetPalette(Palette);
  39.   FOR Color := 0 TO 10000 DO
  40.     BEGIN
  41.       SetColor(Random(Palette.Size));
  42.       Line(Random(GetMaxX),Random(GetMaxY),Random(GetMaxX),Random(GetMaxY));
  43.     END;
  44.  
  45.   REPEAT
  46.     REPEAT I := Random(Palette.Size) UNTIL I <> 0;
  47.     SetPalette(I,Random(Palette.Size));
  48.   UNTIL KeyPressed;
  49.  
  50.   CloseGraph;
  51.  
  52. END.
  53.